package cn.edu.hit.service;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import cn.edu.hit.db.*;
import cn.edu.hit.javabean.*;
public class DictionaryService {
	private static DBTools dbtools = new DBTools();
	public static List<Dictionary> getDictionaryByAttributeName(String attributeName){
		ArrayList<Dictionary> dictionarys = new ArrayList<Dictionary>();
		String sql = "select * from attribute , attributeditail where attribute.id = attributeditail.attributeid AND" +
				" attribute.attributename='"+attributeName+"'";
		//System.out.println(sql);
		ResultSet rs = dbtools.executeQuery(sql);
		try {
			Dictionary dic = null;
			while(rs.next())
			{
				int id = rs.getInt("id");
				int delegate = rs.getInt("delegate");
				String attrName = rs.getString("attributename");
				String realValue = rs.getString("realValue");
				dic = new Dictionary(id,delegate,attrName,realValue);
				dictionarys.add(dic);	
			}
			return dictionarys;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return dictionarys;
	}
	public static String sayHello(String yourName){
		return "hello world"+yourName;
	}
}
